<!--黑名单维护-->
<template>
  <div class="app-container">
    <ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :labelWidth="100"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :defaultEventKey="defaultEventKey"
    ></ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="blacklistName,source,fileType"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="200px" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '修改',
                  doFunc: () => {
                    edit(scope.row);
                  },
                },
                {
                  label: '删除',
                  doFunc: () => {
                    del(scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <black-list-add-dialog ref="blackListAddDialog" @editComplete="editComplete"></black-list-add-dialog>

    <black-list-edit-dialog ref="blackListEditDialog" @editComplete="editComplete"></black-list-edit-dialog>
  </div>
</template>
<script>
import { blackListMaintainUrlConfig, blackListDelete } from "@/api/cnaps/bizMng/blackList.js";
import { listPageMixin } from "@/libs/listPageMixin";
import BlackListAddDialog from "./addDialog";
import BlackListEditDialog from "./editDialog";

export default {
  name: "blackList_maintain",
  mixins: [listPageMixin],
  components: {
    BlackListAddDialog,
    BlackListEditDialog,
  },
  props: {},
  data() {
    return {
      reqConfig: blackListMaintainUrlConfig,
      defaultEventKey: "",
      //数据字典
      searchFormDictList: ["DATE_SOURCE", "FILE_TYPE"],
      // 遮罩层
      loading: true,
      // 弹出层标题
      title: "",
      showSearch: true,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        conSource:"",
        conBlacklistName:"",
        fileType:"",
      },
      formOptions: [],
      opButtonList: () => {
        return [
          {
            label: "新增",
            type: "primary",
            icon: "el-icon-plus",
            actionType: "add",
            clickFun: () => {
              this.add();
            },
          },
        ];
      },
      tableBindColumns: [
        { label: `黑名单名称`, prop: "blacklistName", align: "center" },
        { label: `类型`, prop: "fileType", align: "center", dictCode: "FILE_TYPE" },
        { label: `黑名单备注`, prop: "remarks", align: "center" },
        { label: `来源`, prop: "source", align: "center", dictCode: "DATE_SOURCE" },
      ],
    };
  },
  mounted() {
    // this.getList()
    this.formOptions = [
      {
        type: "dict",
        dict: "DATE_SOURCE",
        prop: "conSource",
        defaultAttr: {
          label: "来源",
          placeholder: "请选择来源",
        },
      },
      {
        type: "input",
        prop: "conBlacklistName",
        defaultAttr: {
          label: "黑名单名称",
          placeholder: "请输入黑名单名称",
        },
      },
      {
        type: "dict",
        dict: "FILE_TYPE",
        prop: "fileType",
        defaultAttr: {
          label: "类型",
          placeholder: "请选择类型",
        },
      },
    ];
  },
  methods: {
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    add() {
      console.log("this.$refs.blackListAddDialog", this.$refs.blackListAddDialog);
      this.$refs.blackListAddDialog.show();
    },
    edit(row) {
      console.log("this.$refs.blackListEditDialog", this.$refs.blackListEditDialog);
      this.$refs.blackListEditDialog.show(row);
    },
    del(row) {
      this.$confirm("确认删除该条黑名单维护信息?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return blackListDelete(row);
        })
        .then(() => {
          this.handleQuery();
          this.msgSuccess("删除提交成功");
        })
        .catch((action) => {});
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
